import request from '@/utils/request'

export function login(aname, apwd) {
  // 登陆接口
  return request({
    url: '/admins/selectbynamepwd.action',
    method: 'post',
    data: {
      aname,
      apwd
    }
  })
}

export function getInfo() {
  return request({
    url: '/selectbyid.action',
    method: 'get',
  })
}

export function logout() {
  return request({
    url: '/admin/logout',
    method: 'post'
  })
}
// 查询管理员列表
export function fetchList(data) {
  return request({
    url: '/admins/selectalladmin.action',
    method: 'post',
    data
  })
}
// 创建管理员
export function createAdmin(data) {
  return request({
    url: '/admins/insertSelective.action',
    method: 'post',
    data
  })
}
// 修改管理员密码
export function updateAdmin(data) {
  return request({
    url: '/admins/updateByPrimaryKeySelective.action',
    method: 'post',
    data: data
  })
}

export function updateStatus(id, params) {
  return request({
    url: '/admin/updateStatus/' + id,
    method: 'post',
    params: params
  })
}
// 删除管理员
export function deleteAdmin(params) {
  return request({
    url: '/admins/deleteByPrimaryKey.action',
    method: 'get',
    params
  })
}

export function getRoleByAdmin(id) {
  return request({
    url: '/admin/role/' + id,
    method: 'get'
  })
}

export function allocRole(data) {
  return request({
    url: '/admin/role/update',
    method: 'post',
    data: data
  })
}
